'use strict';
import * as vscode from 'vscode';

import * as client from "vscode-languageclient"


function getConfig(option: string):any {
    const config = vscode.workspace.getConfiguration("lulsp");
    return config.get(option);
}

export function activate(context: vscode.ExtensionContext) {
    const lulsp : client.Executable ={
        command:getConfig('path'),
        args:getConfig('args'),
    };
    var serveropt : client.ServerOptions = lulsp;
    
    var clientopt:client.LanguageClientOptions = {
        documentSelector:[{scheme:"file",pattern:'**/*.{lua}'}],
        synchronize:{
            fileEvents: vscode.workspace.createFileSystemWatcher('**/.clientrc')
        }
    }

    const luclient = new client.LanguageClient("lu Server",serveropt,clientopt);
    luclient.start();
}

export function deactivate() {
}